home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / bsrc_250.zip / VERSION7.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  16KB  |  477 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*                  This module was adapted by Bill Andrus                  */
  14. /*                With the usual kibitzing by Vince Perriello               */
  15. /*                                                                          */
  16. /*              BinkleyTerm Version7 Nodelist processing module             */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. /* Include this file before any other includes or defines! */
  47.  
  48. #include "includes.h"
  49.  
  50. /* This table has been modified to minimize searches */
  51. char unwrk[] = " EANROSTILCHBDMUGPKYWFVJXZQ-'0123456789";
  52.  
  53. long btree (char *, void *, int (*)(void *, void *, int));
  54. int get_ver7_info (unsigned long, ADDRP);
  55. struct _ndx far *get7node(HFILE, unsigned long, struct _ndx far *);
  56. void unpk(char *instr,char *outp,int many);
  57. int addr_compare (void *, void *, int);
  58. int name_compare (void *, void *, int);
  59. extern void get_nodelist_name (ADDRP);
  60.  
  61. extern char *nodelist_base;
  62. extern char *nodelist_name;
  63. static char  index_filename[260];
  64.  
  65. static int namelen;
  66.  
  67. static struct _ndx far *nodeidx = NULL;              /* index file             */
  68. static struct _ndx far *noderef = NULL;              /* index file             */
  69.  
  70.  
  71. int ver7find (ADDRP opus_addr, int have_boss_data)
  72. {
  73.     long record;
  74.     ADDR found_addr;
  75.  
  76.     have_boss_data = have_boss_data;
  77.  
  78.     newnodedes.NetNumber = newnodedes.NodeNumber = 0;
  79.  
  80.     get_nodelist_name (opus_addr);              /* fill in nodelist.base  */
  81.     index_filename[0] = '\0';                   /* "null-terminated string*/
  82.     (void) strcpy (index_filename, net_info);   /* take nodelist path     */
  83.     (void) strcat (index_filename, nodelist_base); /* add in the file name*/
  84.     (void) strcat (index_filename, ".NDX");     /* add in the file ext    */
  85.  
  86.     record = btree (index_filename, (void *)opus_addr, addr_compare);
  87.  
  88.     if (record == -1)
  89.        return (0);
  90.     else
  91.        return (get_ver7_info((unsigned long)record, &found_addr));
  92. }
  93.  
  94. int addr_compare (void *key, void *desired, int len)
  95. {
  96.    int k;
  97.  
  98.    k = ((ADDRP)key)->Zone - ((ADDRP)desired)->Zone;
  99.    if (k)
  100.       return (k);
  101.  
  102.    k = ((ADDRP)key)->Net - ((ADDRP)desired)->Net;
  103.    if (k)
  104.       return (k);
  105.  
  106.    k = ((ADDRP)key)->Node - ((ADDRP)desired)->Node;
  107.    if (k)
  108.       return (k);
  109. /*
  110.  * Node matches.
  111.  *
  112.  * The rule for points:
  113.  *  1) If len == 6, treat key value for Point as Zero.
  114.  *  2) Return comparison of key Point and desired Point.
  115.  */
  116.    if (len == 6)
  117.       ((ADDRP)key)->Point = 0;
  118.  
  119.    return ((ADDRP)key)->Point - ((ADDRP)desired)->Point;
  120.  
  121. void opususer (char *name, ADDRP faddr)
  122. {
  123.    char last_name_first[80];
  124.    char midname[80];
  125.    char *c, *p, *m;
  126.    long record;
  127.  
  128.    faddr->Zone = faddr->Net = faddr->Node = faddr->Point = (unsigned int) -1;
  129.    faddr->Domain = NULL;
  130.  
  131.    c = midname;                                  /* Start of temp name buff   */
  132.    p = name;                                     /* Point to start of name    */
  133.    m = NULL;                                     /* Init pointer to space     */
  134.  
  135.    *c = *p++;
  136.    while (*c)                                    /* Go entire length of name  */
  137.    {
  138.       if (*c == ' ')                             /* Look for space            */
  139.          m = c;                                  /* Save location             */
  140.       c++;
  141.       *c = *p++;
  142.    }
  143.  
  144.    if (m != NULL)                                /* If we have a pointer,     */
  145.    {
  146.       *m++ = '\0';                               /* Terminate the first half  */
  147.       (void) strcpy (last_name_first, m);        /* Now copy the last name    */
  148.       (void) strcat (last_name_first, ", ");     /* Insert a comma and space  */
  149.       (void) strcat (last_name_first, midname);  /* Finally copy first half   */
  150.    }
  151.    else (void) strcpy (last_name_first, midname);/* Use whole name otherwise  */
  152.  
  153.    (void) fancy_str (last_name_first);           /* Get caps in where needed  */
  154.    namelen = (int) strlen (last_name_first);     /* Calc length now           */
  155.  
  156.    index_filename[0] = '\0';                     /* "null-terminated string"  */
  157.  
  158.    if (nodelist_base == NULL)
  159.       get_nodelist_name (&my_addr);              /* fill in nodelist.base     */
  160.    (void) strcpy (index_filename, net_info);     /* take nodelist path        */
  161.    (void) strcat (index_filename, "SYSOP.NDX");  /* add in the file name      */
  162.  
  163.    record = btree (index_filename, (void *)last_name_first, name_compare);
  164.  
  165.    if (record == -1)
  166.       return;
  167.  
  168.    (void) get_ver7_info((unsigned long)record, faddr);
  169. }
  170.  
  171. int name_compare (void *key, void *desired, int len)
  172. {
  173.    return (strnicmp ((char *)key, (char *)desired, (unsigned int) min (namelen,len)));
  174. }
  175.  
  176. /*
  177.  * General V7 nodelist engine. Used by both the by-node and by-sysop
  178.  * lookups.
  179.  *
  180.  * Thanks to Phil Becker for showing me how nice it looks in assembler.
  181.  * It helped me see how nice it could be in C.
  182.  *
  183.  * (I know, Phil, it's still nicer in assembler!)
  184.  *
  185.  */
  186.  
  187. long